home *** CD-ROM | disk | FTP | other *** search
/ Aminet 15 / Aminet 15 - Nov 1996.iso / Aminet / dev / basic / ace24dist.lha / ace24.lha / include / libraries / iffparse.h < prev    next >
C/C++ Source or Header  |  1996-09-10  |  9KB  |  289 lines

  1. #ifndef IFF_IFFPARSE_H
  2. #define IFF_IFFPARSE_H
  3. /*
  4. ** iffparse.h for ACE Basic
  5. **
  6. ** Note: Translated to ACE by ConvertC2ACE
  7. **       @ MapMeadow Software, Nils Sjoholm
  8. **
  9. **
  10. ** Date: 09/01/95
  11. **
  12. **
  13. */
  14.  
  15. /*
  16. ** This are the StructPointer defines for iffparse.h
  17. */
  18. #ifndef ClipboardHandlePtr
  19. #define ClipboardHandlePtr ADDRESS
  20. #endif
  21. #ifndef CollectionItemPtr
  22. #define CollectionItemPtr ADDRESS
  23. #endif
  24. #ifndef ContextNodePtr
  25. #define ContextNodePtr ADDRESS
  26. #endif
  27. #ifndef IFFHandlePtr
  28. #define IFFHandlePtr ADDRESS
  29. #endif
  30. #ifndef IFFStreamCmdPtr
  31. #define IFFStreamCmdPtr ADDRESS
  32. #endif
  33. #ifndef LocalContextItemPtr
  34. #define LocalContextItemPtr ADDRESS
  35. #endif
  36. #ifndef StoredPropertyPtr
  37. #define StoredPropertyPtr ADDRESS
  38. #endif
  39. /*
  40. ** End of StructPointer defines for iffparse.h
  41. */
  42.  
  43.  
  44. /*****************************************************************************/
  45.  
  46.  
  47. #ifndef EXEC_TYPES_H
  48. #include <exec/types.h>
  49. #endif
  50.  
  51. #ifndef EXEC_LISTS_H
  52. #include <exec/lists.h>
  53. #endif
  54.  
  55. #ifndef EXEC_PORTS_H
  56. #include <exec/ports.h>
  57. #endif
  58.  
  59. #ifndef DEVICES_CLIPBOARD_H
  60. #include <devices/clipboard.h>
  61. #endif
  62.  
  63.  
  64. /*****************************************************************************/
  65.  
  66.  
  67. /* Structure associated with an active IFF stream.
  68.  * "iff_Stream" is a value used by the client's read/write/seek functions -
  69.  * it will not be accessed by the library itself and can have any value
  70.  * (could even be a pointer or a ADDRESS).
  71.  *
  72.  * This structure can only be allocated by iffparse.library
  73.  */
  74. STRUCT IFFHandle
  75.  
  76.     LONGINT iff_Stream 
  77.     LONGINT iff_Flags 
  78.     LONGINT  iff_Depth     /*  Depth of context stack */
  79. END STRUCT 
  80.  
  81. /* bit masks for "iff_Flags" field */
  82. #define IFFF_READ   0&           /* read mode - default    */
  83. #define IFFF_WRITE  1&           /* write mode         */
  84. #define IFFF_RWBITS (IFFF_READ OR IFFF_WRITE) /* read/write bits    */
  85. #define IFFF_FSEEK  (2&)      /* forward seek only      */
  86. #define IFFF_RSEEK  (4)      /* random seek    */
  87. #define IFFF_RESERVED   &HFFFF0000&      /* Don't touch these bits */
  88.  
  89.  
  90. /*****************************************************************************/
  91.  
  92.  
  93. /* When the library calls your stream handler,  you'll be passed a pointer
  94.  * to this structure as the "message packet".
  95.  */
  96. STRUCT IFFStreamCmd
  97.  
  98.     LONGINT sc_Command     /* Operation to be performed (IFFCMD_) */
  99.     ADDRESS sc_Buf     /* Pointer to data buffer          */
  100.     LONGINT sc_NBytes  /* Number of bytes to be affected      */
  101. END STRUCT 
  102.  
  103.  
  104. /*****************************************************************************/
  105.  
  106.  
  107. /* A node associated with a context on the iff_Stack. Each node
  108.  * represents a chunk,  the stack representing the current nesting
  109.  * of chunks in the open IFF file. Each context node has associated
  110.  * local context items in the (private) LocalItems list.  The ID,  type, 
  111.  * size and scan values describe the chunk associated with this node.
  112.  *
  113.  * This structure can only be allocated by iffparse.library
  114.  */
  115. STRUCT ContextNode
  116.  
  117.     MinNode cn_Node 
  118.     LONGINT       cn_ID 
  119.     LONGINT       cn_Type 
  120.     LONGINT       cn_Size  /*  Size of this chunk         */
  121.     LONGINT       cn_Scan  /*  # of bytes read/written so far */
  122. END STRUCT 
  123.  
  124.  
  125. /*****************************************************************************/
  126.  
  127.  
  128. /* Local context items live in the ContextNode's.  Each class is identified
  129.  * by its lci_Ident code and has a (private) purge vector for when the
  130.  * parent context node is popped.
  131.  *
  132.  * This structure can only be allocated by iffparse.library
  133.  */
  134. STRUCT LocalContextItem
  135.  
  136.     MinNode lci_Node 
  137.     LONGINT      lci_ID 
  138.     LONGINT      lci_Type 
  139.     LONGINT      lci_Ident 
  140. END STRUCT 
  141.  
  142.  
  143. /*****************************************************************************/
  144.  
  145.  
  146. /* StoredProperty: a local context item containing the data stored
  147.  * from a previously encountered property chunk.
  148.  */
  149. STRUCT StoredProperty
  150.  
  151.     LONGINT sp_Size 
  152.     ADDRESS sp_Data 
  153. END STRUCT 
  154.  
  155.  
  156. /*****************************************************************************/
  157.  
  158.  
  159. /* Collection Item: the actual node in the collection list at which
  160.  * client will look. The next pointers cross context boundaries so
  161.  * that the complete list is accessable.
  162.  */
  163. STRUCT CollectionItem
  164.  
  165.     CollectionItemPtr  ci_Next 
  166.     LONGINT           ci_Size 
  167.     ADDRESS           ci_Data 
  168. END STRUCT 
  169.  
  170.  
  171. /*****************************************************************************/
  172.  
  173.  
  174. /* Structure returned by OpenClipboard(). You may do CMD_POSTs and such
  175.  * using this structure. However,  once you call OpenIFF(),  you may not
  176.  * do any more of your own I/O to the clipboard until you call CloseIFF().
  177.  */
  178. STRUCT ClipboardHandle
  179.  
  180.     IOClipReq cbh_Req 
  181.     MsgPort cbh_CBport 
  182.     MsgPort cbh_SatisfyPort 
  183. END STRUCT 
  184.  
  185.  
  186. /*****************************************************************************/
  187.  
  188.  
  189. /* IFF return codes. Most functions return either zero for success or
  190.  * one of these codes. The exceptions are the read/write functions which
  191.  * return positive values for number of bytes or records read or written, 
  192.  * or a negative error code. Some of these codes are not errors per sae, 
  193.  * but valid conditions such as EOF or EOC (End of Chunk).
  194.  */
  195. #define IFFERR_EOF    -1&   /* Reached logical end of file  */
  196. #define IFFERR_EOC    -2&   /* About to leave context   */
  197. #define IFFERR_NOSCOPE    -3&   /* No valid scope for property  */
  198. #define IFFERR_NOMEM      -4&   /* Internal memory alloc failed */
  199. #define IFFERR_READ   -5&   /* Stream read error        */
  200. #define IFFERR_WRITE      -6&   /* Stream write error       */
  201. #define IFFERR_SEEK   -7&   /* Stream seek error        */
  202. #define IFFERR_MANGLED    -8&   /* Data in file is corrupt  */
  203. #define IFFERR_SYNTAX     -9&   /* IFF syntax error     */
  204. #define IFFERR_NOTIFF     -10&  /* Not an IFF file      */
  205. #define IFFERR_NOHOOK     -11&  /* No call-back hook provided   */
  206. #define IFF_RETURN2CLIENT -12&  /* Client handler normal return */
  207.  
  208.  
  209. /*****************************************************************************/
  210.  
  211. /* Universal IFF identifiers */
  212. #define ID_FORM   1179603533 
  213. #define ID_LIST   1279873876 
  214. #define ID_CAT    1128354848 
  215. #define ID_PROP   1347571536 
  216. #define ID_NULL   538976288 
  217.  
  218. /* Identifier codes for universally recognized local context items */
  219. #define IFFLCI_PROP         1886547824 
  220. #define IFFLCI_COLLECTION   1668246636 
  221. #define IFFLCI_ENTRYHANDLER 1701734500 
  222. #define IFFLCI_EXITHANDLER  1702389860 
  223.  
  224.  
  225. /*****************************************************************************/
  226.  
  227.  
  228. /* Control modes for ParseIFF() function */
  229. #define IFFPARSE_SCAN    0&
  230. #define IFFPARSE_STEP    1&
  231. #define IFFPARSE_RAWSTEP 2&
  232.  
  233.  
  234. /*****************************************************************************/
  235.  
  236.  
  237. /* Control modes for StoreLocalItem() function */
  238. #define IFFSLI_ROOT  1&  /* Store in default context      */
  239. #define IFFSLI_TOP   2&  /* Store in current context      */
  240. #define IFFSLI_PROP  3&  /* Store in topmost FORM or LIST */
  241.  
  242.  
  243. /*****************************************************************************/
  244.  
  245.  
  246. /* Magic value for writing functions. If you pass this value in as a size
  247.  * to PushChunk() when writing a file,  the parser will figure out the
  248.  * size of the chunk for you. If you know the size,  is it better to
  249.  * provide as it makes things faster.
  250.  */
  251. #define IFFSIZE_UNKNOWN -1&
  252.  
  253.  
  254. /*****************************************************************************/
  255.  
  256.  
  257. /* Possible call-back command values */
  258. #define IFFCMD_INIT 0   /* Prepare the stream for a session */
  259. #define IFFCMD_CLEANUP  1   /* Terminate stream session     */
  260. #define IFFCMD_READ 2   /* Read bytes from stream       */
  261. #define IFFCMD_WRITE    3   /* Write bytes to stream        */
  262. #define IFFCMD_SEEK 4   /* Seek on stream           */
  263. #define IFFCMD_ENTRY    5   /* You just entered a new context   */
  264. #define IFFCMD_EXIT 6   /* You're about to leave a context  */
  265. #define IFFCMD_PURGELCI 7   /* Purge a LocalContextItem     */
  266.  
  267.  
  268. /*****************************************************************************/
  269.  
  270.  
  271. /* Obsolete IFFParse definitions,  here for source code compatibility only.
  272.  * Please do NOT use in new code.
  273.  *
  274.  * #define IFFPARSE_V37_NAMES_ONLY to remove these older names
  275.  */
  276. #ifndef IFFPARSE_V37_NAMES_ONLY
  277. #define IFFSCC_INIT IFFCMD_INIT
  278. #define IFFSCC_CLEANUP  IFFCMD_CLEANUP
  279. #define IFFSCC_READ IFFCMD_READ
  280. #define IFFSCC_WRITE    IFFCMD_WRITE
  281. #define IFFSCC_SEEK IFFCMD_SEEK
  282. #endif
  283.  
  284.  
  285. /*****************************************************************************/
  286.  
  287.  
  288. #endif /* IFFPARSE_H */
  289.